<!-- 底部结算 -->
<template>
	<view class="container" :class="{'active': !useShoppingCart.isShowDelete}"
		:style="{'paddingBottom': safeAreaBottom}">
		<!-- 结算操作 -->
		<view class="operation">
			<view class="radio-label" @click="checked = !checked">
				<text class="checkbox iconfont" :class="{'active': checked}">
					{{checked ? '&#xe62c;': '&#xe6a6;'}}
				</text>
				<text class="text">全选</text>
			</view>
			<view class="summary">
				<view class="summary-box">
					<text class="label">合计：</text>
					<text class="unit">￥</text>
					<text class="sum">39.60</text>
				</view>
				<view class="discount-box">
					<text class="label">总优惠</text>
					<text class="sum">￥20.00</text>
				</view>
			</view>
			<button class="submit-btn btn-transition-scale95" @click="handleSubmit()">
				<text class="main">一键结算</text>
				<text class="sub">2个商家</text>
			</button>
		</view>
	</view>
</template>

<script setup>
	import { onBeforeMount, ref } from 'vue';
	import { useShoppingCartStore } from '../store.js';

	const props = defineProps({
		height: '',
		visible: false,
	});
	const emits = defineEmits('update:height');

	const safeAreaBottom = getApp().globalData.safeAreaBottom + 'px'; // 底部安全区域高度
	const useShoppingCart = useShoppingCartStore();
	const checked = ref(false);

	onBeforeMount(() => {
		emits('update:height', '122rpx');
	});


	const handleSubmit = () => {
		uni.navigateTo({
			url: '/pagesC-shopping/submit-order/index'
		})
	}
</script>

<style lang="scss" scoped>
	.container {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		transform: translateY(100%);
		transition: transform 0.2s;

		&.active {
			transform: translateY(0);
		}
	}

	.operation {
		display: flex;
		align-items: center;
		height: 122rpx;
		padding: 0 38rpx 0 28rpx;

		.radio-label {
			flex-grow: 1;
			display: flex;
			align-items: center;

			.checkbox {
				flex-shrink: 0;
				font-size: 40rpx;
				color: #DCDCDC;
				margin-right: 10rpx;
			
				&.active {
					color: #FE3333;
				}
			}

			.text {
				font-weight: 500;
				font-size: 24rpx;
				color: #999999;
			}
		}

		.summary {
			&-box {
				display: flex;
				align-items: flex-end;

				.label {
					font-size: 24rpx;
					color: #222222;
					line-height: 1.3;
				}

				.unit {
					font-weight: bold;
					font-size: 24rpx;
					color: #FE3333;
					line-height: 1.3;
				}

				.sum {
					font-weight: bold;
					font-size: 33rpx;
					color: #FE3333;
					line-height: 1;
				}
			}

			.discount-box {
				text-align: right;
				
				.label {
					font-size: 20rpx;
					color: #222;
				}

				.sum {
					font-size: 20rpx;
					color: #FE3333;
				}
			}
		}

		.submit-btn {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			width: 198rpx;
			height: 72rpx;
			background: #FE3333;
			border-radius: 36rpx;
			margin-left: 28rpx;

			.main {
				font-weight: bold;
				font-size: 28rpx;
				color: #FFFFFF;
			}

			.sub {
				font-size: 18rpx;
				color: white;
			}
		}
	}
</style>